//
//  ShopDetailTableViewCell.m
//  ShouYi
//
//  Created by yrapp on 16/3/10.
//  Copyright © 2016年 yurui. All rights reserved.
//

#import "ShopDetailTableViewCell.h"

@implementation ShopDetailTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {

        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        _title = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, kWidth, 10)];
        _title.numberOfLines = 0;
        _title.text = @"51174asdrcac4q6fvhbhncnicejncncncn i fnihn iufn uimnuimn cxmnxdkhkjsfhmkjklxfjkx mj cnjdfkcjkffjkknhrcytbf yunxguiecuixhnmahnwexljesljcf cjfcmjnmjc grcgjmrcjrmvgumcrgjm";
        //_title.font = [UIFont systemFontOfSize:14];
        [_title sizeToFit];
        [self.contentView addSubview:_title];
        
        _nowprice = [[UILabel alloc] initWithFrame:CGRectMake(10, 40, kWidth / 2, 30)];
        _nowprice.numberOfLines = 0;
        [self.contentView addSubview:_nowprice];
        
        _fanxian = [[UILabel alloc] initWithFrame:_nowprice.frame];
        _fanxian.textColor = [UIColor redColor];
        [self.contentView addSubview:_fanxian];
        
        _fengeLine = [[UIView alloc] initWithFrame:CGRectMake(kWidth - 100, 50, 1.5, 30)];
        _fengeLine.backgroundColor = [UIColor colorWithRed:223.0/255 green:224.0/255 blue:225.0/255 alpha:1];
        [self.contentView addSubview:_fengeLine];
        
        
        
        _oldPrice = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, kWidth / 2, 30)];
        [self.contentView addSubview:_oldPrice];
        
        _yunfei = [[UILabel alloc] initWithFrame:CGRectMake(0, _oldPrice.frame.size.height + _oldPrice.frame.origin.y + 10, kWidth,10)];
        _yunfei.text = @"运费:免运费";
        [self.contentView addSubview:_yunfei];
        
    }
    
    return self;
    
}

- (void)setModel:(prolistModel *)model {
    
    _title.text = model.title;
    [_title sizeToFit];
    
    _nowprice.text = [NSString stringWithFormat:@"￥%@~%@",model.hyj,model.scj];
    _nowprice.textColor = [UIColor redColor];
    //_nowprice.font = [UIFont systemFontOfSize:20];
    _nowprice.frame = CGRectMake(10, _title.frame.size.height + _title.frame.origin.y + 10, kWidth / 2, 30);
    [_nowprice sizeToFit];
    
    _oldPrice.text = [NSString stringWithFormat:@"原价:¥ %@",model.scj];
    _oldPrice.textColor = [UIColor grayColor];
    _oldPrice.font = [UIFont systemFontOfSize:13];
    _oldPrice.frame = CGRectMake(10, _nowprice.frame.size.height + _nowprice.frame.origin.y + 10, kWidth / 2, 30);
    [_oldPrice sizeToFit];
    
    _fanxian.text = @"¥ 7.98~9.66";
    [_fanxian sizeToFit];
    _fanxian.frame = CGRectMake(kWidth - _fanxian.frame.size.width - 10,_nowprice.frame.origin.y, _fanxian.frame.size.width, _fanxian.frame.size.height);
    
    
    _fengeLine.frame = CGRectMake(_fanxian.frame.origin.x - 15, _fanxian.frame.origin.y + 2, 1, 30);
    
    _yunfei.frame = CGRectMake(10, _oldPrice.frame.size.height + _oldPrice.frame.origin.y + 10, kWidth,20);
    _yunfei.text = @"运费:免运费";
    _yunfei.font = [UIFont systemFontOfSize:14];
    [_yunfei sizeToFit];
    [self.contentView addSubview:_yunfei];
    
    UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, _yunfei.frame.size.height + _yunfei.frame.origin.y + 10, kWidth,10)];
    backView.backgroundColor = kViewBackColor;
    [self.contentView addSubview:backView];
}

// 计算 高度
- (CGFloat)setModelForHeight:(prolistModel *)model {
    
    _title = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, kWidth, 10)];
    _title.numberOfLines = 0;
    _title.text = model.title;
    [_title sizeToFit];
    
    _nowprice.text = model.hyj;
    _nowprice.frame = CGRectMake(10, _title.frame.size.height + _title.frame.origin.y + 10, kWidth / 2, 30);
    [_nowprice sizeToFit];
    
    _oldPrice.text = model.scj;
    _oldPrice.frame = CGRectMake(10, _nowprice.frame.size.height + _nowprice.frame.origin.y + 10, kWidth / 2, 30);
    [_oldPrice sizeToFit];
    
    _yunfei.frame = CGRectMake(0, _oldPrice.frame.size.height + _oldPrice.frame.origin.y + 10, kWidth,20);

    
    return _yunfei.frame.size.height + _yunfei.frame.origin.y + 20;
}

- (void)awakeFromNib {
    // Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
